﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GM.Forms
{
    public partial class ReportForm : Form
    {

        public ReportForm()
        {
            InitializeComponent();
        }

        public void Show(String reportName, object data, string dsname)
        {
            Microsoft.Reporting.WinForms.ReportDataSource reportDataSource = new Microsoft.Reporting.WinForms.ReportDataSource();
            
            reportDataSource.Name = dsname;

            reportDataSource.Value = data;

            this.reportViewer.LocalReport.DataSources.Clear();
            this.reportViewer.LocalReport.DataSources.Add(reportDataSource);
            this.reportViewer.LocalReport.ReportEmbeddedResource = String.Format("GM.{0}.rdlc",reportName);
            this.reportViewer.RefreshReport();

            this.Show();
        }

        private void ReportForm_Load(object sender, EventArgs e)
        {
            this.reportViewer.RefreshReport();
        }

        private void ReportForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }

    }
}
